/*    */ package com.mbl.phone.service;
/*    */ import java.sql.Timestamp;

/*    */ import javax.annotation.Resource;

/*    */ import org.apache.shiro.SecurityUtils;
/*    */ import org.slf4j.Logger;
/*    */ import org.slf4j.LoggerFactory;
/*    */ import org.springframework.stereotype.Service;

/*    */ 
/*    */ import com.mbl.phone.dao.UserDao;
/*    */ import com.mbl.phone.pojo.User;
/*    */ import com.mbl.phone.realm.jdbcRealm;
/*    */ 
/*    */ @Service("UserService")
/*    */ public class UserServiceImpl implements UserService
/*    */ {
/* 18 */   static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);
/*    */   
/*    */   @Resource
/*    */   UserDao userDao;
/*    */   
/*    */   public User selectTokenByUsername(String username)
/*    */   {
/* 25 */     return this.userDao.selectTokenByUsername(username);
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   public Integer modifyUser(String oldPaw, String newPaw)
/*    */   {
/* 34 */     User user = (User)SecurityUtils.getSubject().getSession().getAttribute("user");
/* 35 */     String hashKey = jdbcRealm.getHashKey("MD5", 2, oldPaw, user.getNickname());
/*    */     
/* 37 */     if (user.getPassword().equals(hashKey)) {
/* 38 */       user.setUpdata_time(new Timestamp(System.currentTimeMillis()));
/* 39 */       String newPass = jdbcRealm.getHashKey("MD5", 2, newPaw, user.getNickname());
/* 40 */       user.setPassword(newPass);
/*    */       
/* 42 */       return this.userDao.updatePassword(user);
/*    */     }
/*    */     
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/* 52 */     return Integer.valueOf(2);
/*    */   }
/*    */ }


/* Location:              C:\Users\Administrator\Desktop\phone.war!\WEB-INF\classes\com\mbl\phone\service\UserServiceImpl.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       0.7.1
 */